/ Assembly List / LJCDataAccess / DataAccess / FillDataTable

Namespace - LJCDataAccess


Parameters
sql - The Select SQL statement.
dataTable - The DataTable object.
tableMapping - The table map collection.

Syntax

C#
public Void FillDataTable(String sql, DataTable dataTable, DataTableMappingCollection tableMapping = null)

Executes a Select statement and fills the specified DataTable. (E)

Remarks

This method is useful for populating standard DataTable objects and strongly typed DataTable objects.

Example

C#
// See the DataAccess setup code on the DataAccess class page.

// Executes a Select statement and fills the specified DataTable.
private static void FillDataTable(DataAccess dataAccess)
{
  string sql = "select * from TableName";
  DataTable dataTable = new DataTable();

  dataAccess.FillDataTable(sql, dataTable);
  if (dataTable != null)
  {
    foreach (DataRow dataRow in dataTable.Rows)
    {
      for int index = 0; index < dataTable.Columns.Count; index++)
      {
        string value = dataRow[index].ToString();
      }
    }
  }
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.